/**
 * Created by Administrator on 2017/7/3.
 */
var vm_download = avalon.define({
    $id: "download",
    bossImg:'',
    subColumn:[],
    columnContent: [],
    currentContent:[],
    toggle:false,
    // columnTitle: []
    tnTab:function () {
        var n = 0;
        var self = this;
        // n = ( self.currentIndex == 0 ? 0 : self.currentIndex);
        $(".tnTab li").eq(n).addClass("active").siblings().removeClass("active")
        console.log('self.currentContent = '+self.currentContent)
        $(".tnTab li a").click(function () {
           n = $(".tnTab li a").index($(this));
            // $(".tnTabContent").eq(n).addClass("current").siblings().removeClass("current");
            $(".tnTab li").eq(n).addClass("active").siblings().removeClass("active");
            self.currentContent = self.columnContent[n];
        })
    },
    changeState: function () {
        this.toggle = !this.toggle;
    }
})
getColumnId();
function getColumnId() {
    var pageNumber = getServiceColumnId('资料下载');
    console.log('pageNumber=' + pageNumber);
    var subColumnIdArr = [];
    var _basePath = getChildUrl(pageNumber);
    console.log(_basePath);
    $.frontEngineAjax.ajaxRequest(function (data) {
        var tempOption;
        for (var i = 0, len = data.length; i < len; i++) {
            var name = data[i].name;
            tempOption = {
                "name": name,
                "number": data[i].number
            }
            subColumnIdArr[i] = tempOption;
        }
        console.log(subColumnIdArr);
        vm_download.subColumn = subColumnIdArr;
       getSubColumnData(subColumnIdArr)
    }, _basePath)
}

var index = 0;
function getSubColumnData(ColumnIdArr) {
    var lenth = ColumnIdArr.length;
    console.log(lenth);
    var _basePath = getDataUrl(ColumnIdArr[index].number);
    console.log("getColumnData _basePath=" + _basePath);
    $.frontEngineAjax.ajaxRequest(function (data) {
        vm_download.columnContent.push(data);
        if (index < lenth - 1) {
            index++;
            getSubColumnData(ColumnIdArr);
        }else{
            vm_download.currentContent = vm_download.columnContent[0];
            console.log(vm_download.currentContent.length)
        }
    }, _basePath);


}
